<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>----------</title>
<script type="text/javascript" src="ext/ext-all.js"></script>
<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />
<script type="text/javascript">
	Ext.onReady(function() {
		var window = Ext.create('Ext.window.Window', {
		    title: 'Admin Login',
		    layout:'form',
		    width: 300,
		    plain:true,
		    closable:false,
		    draggable:false,
		    resizable:false,
		    items: [{
		        xtype: 'textfield',
		        id:'userName',
		        emptyText:'Account',
		        enableKeyEvents: true, 
		        listeners:{
		        	"keypress":function(event){
		        		if(Ext.EventObject.getKey()==13){
		        			Ext.getCmp("pwd").focus();
		        		}
		        	}
		        }
		    }, {
		        xtype: 'textfield',
		        id:'pwd',
		        inputType: 'password',
		        emptyText:'Password',
		        margin:'0 0 3 0',
		        enableKeyEvents: true, 
		        listeners:{
		        	"keypress":function(event){
		        		if(Ext.EventObject.getKey()==13){
		        			Ext.getCmp("loginButton").fireEvent("click");
		        		}
		        	}
		        }
		    }],
		    buttons:[{
		    	text:'Login',
		    	id:'loginButton',
		    	listeners:{
		    		"click":function(){
		    			Ext.Ajax.request({
		    			    url: 'Admin!login',
		    			    params: {
		    			        "admin.loginName": Ext.getCmp("userName").getValue(),
		    			        "admin.password":Ext.getCmp("pwd").getValue()
		    			    },
		    			    success: function(response){
		    			        var text = response.responseText;
		    			        var json = Ext.JSON.decode(text);
		    			        if(json.admin==null){
		    			        	Ext.Msg.alert("account or password error");
		    			        }else{
// 		    			        	alert(text);
		    			        	document.location.href="main.html";
		    			        }
		    			    }
		    			});
		    		}
		    	}
		    },{
		    	text:'Reset',
		    	listeners:{
		    		"click":function(){
		    			Ext.getCmp("userName").setValue("");
		    			Ext.getCmp("pwd").setValue("");
		    		}
		    	}
		    }],
		});
		window.show();
		Ext.EventManager.onWindowResize(function(width, height) {
			window.center();
		});
	});
</script>
</head>
<body>
</body>
</html>